import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommentPostsVO, CommentPostsForm, CommentPostsQuery } from '@/api/comment/commentPosts/types';

/**
 * 查询文章评论列表
 * @param query
 * @returns {*}
 */

export const listCommentPosts = (query?: CommentPostsQuery): AxiosPromise<CommentPostsVO[]> => {
  return request({
    url: '/comment/commentPosts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询文章评论详细
 * @param commentId
 */
export const getCommentPosts = (commentId: string | number): AxiosPromise<CommentPostsVO> => {
  return request({
    url: '/comment/commentPosts/' + commentId,
    method: 'get'
  });
};

/**
 * 新增文章评论
 * @param data
 */
export const addCommentPosts = (data: CommentPostsForm) => {
  return request({
    url: '/comment/commentPosts',
    method: 'post',
    data: data
  });
};

/**
 * 修改文章评论
 * @param data
 */
export const updateCommentPosts = (data: CommentPostsForm) => {
  return request({
    url: '/comment/commentPosts',
    method: 'put',
    data: data
  });
};

/**
 * 删除文章评论
 * @param commentId
 */
export const delCommentPosts = (commentId: string | number | Array<string | number>) => {
  return request({
    url: '/comment/commentPosts/' + commentId,
    method: 'delete'
  });
};
